<!DOCTYPE   html>
<html>
<head>
<meta charset="UTF-8">
<title>
</title>
<script type="text/javascript" src="../js/vue-2.6.10.js"></script>
<script type="text/javascript" src="../js/axios.js"></script>
<style>
</style>
</head>
<body>
	<form action="/orderSystem/updateInventory.do" method="Post" id="app">
       	<input type="hidden" v-model='user.id' name="id">
       	<label   for="id">商品id：</label>
        <input    type="id"  v-model="user.id" id="id"   name="id"  required>
       	<label   for="number">商品数量：</label>
        <input    type="id"  v-model="user.number" id="number"   name="number"  required>
        <label   for="inventoryname">商品名称：</label>
        <input    type="text" v-model="user.inventoryname"  id="inventoryname"   name="inventoryname"   required>
        <label   for="price">商品价格：</label>
        <input    type="price"  v-model="user.price" id="price"   name="price"   required>
           <input type="submit"   value="完成">
       </form>
       <script type="text/javascript">
	       function parseUrlParams() {
	    	    var url = window.location.href;
	    	    var paramString = url.split('?')[1];
	    	    var paramPairs = paramString.split('&');
	    	    var params = {};
	    	    paramPairs.reduce(function(params, pair) {
	    	        var parts = pair.split('=');
	    	        var key = parts[0];
	    	        var value = decodeURIComponent(parts[1] || '');
	    	        if (params[key]) {
	    	            params[key].push(value);
	    	        } else {
	    	            params[key] = [value];
	    	        }
	    	        return params;
	    	    }, params);
	    	    return params;
	    	}     		
	       let vue = new Vue({
				el: '#app',
				data:{
					user:{
						inventoryname: '',
						price: '',
						number: ''
					}
				},
				created(){
					params = parseUrlParams();
					//url: 表示异步请求地址
					axios.get('/orderSystem/selectInventoryById.do?id='+params.id[0]).then(
						function(res_obj){
							//使用获取的数据来给vue对象中的users数据赋值
							vue.user = res_obj.data; 
						}
					).catch(
						function(error_obj){
							alert("网络加载异常！！！");
						}
					)
				}
			});
	</script>
</body>
</html>